/********************************************************************
 * Copyright (c) 2005 Ultimania Organization. 
 * All rights reserved. This program and the accompanying materials 
 * are made available under the terms of the Eclipse Public License
 * v1.0 which accompanies this distribution, and is available at
 * http://www.eclipse.org/org/documents/epl-v10.html
 * 
 * Contributors:
 *     tidus - initial implementation. 
 *******************************************************************/

package org.ultimania.middlegenide.wizards;

import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IResource;
import org.eclipse.jface.viewers.IStructuredSelection;

public class WizardNewFileCreationPage extends org.eclipse.ui.dialogs.WizardNewFileCreationPage {
	public WizardNewFileCreationPage(String pageName, IStructuredSelection selection) {
		super(pageName, selection);
		initialize(selection);
 	}
	
	private void initialize(IStructuredSelection selection){
		String fileName = "middlegen-build.xml";
		if (selection!=null && selection.isEmpty()==false && selection instanceof IStructuredSelection) {
			if (selection.size()>1) return;
			Object obj = selection.getFirstElement();
			if (obj instanceof IResource) {
				IContainer container;
				if (!(obj instanceof IContainer)){
					fileName = ((IResource)obj).getName();
				}
			}
		}
		this.setFileName(fileName);
	}

	public String getContainerName(){
		return getContainerFullPath().toString();
	}

	public boolean canFlipToNextPage() {
		return true;
	}
	
}
